package com.board.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import com.board.domain.BoardCommand;

@Component
public class BoardDaoImpl extends SqlSessionDaoSupport implements BoardDao{
	
	@Override
	public void insert(BoardCommand board) {
		getSqlSession().insert("insertBoard",board);
		
	}

	@Override
	public List<BoardCommand> list(Map<String, Object> map) {
		List<BoardCommand> list = getSqlSession().selectList("selectList", map);
		return list;
	}

	@Override
	public int getRowCount(Map<String, Object> map) {
		return getSqlSession().selectOne("selectCount", map);
	}
	@Override
	public BoardCommand selectBoard(Integer bo_num) {
		BoardCommand command = (BoardCommand)getSqlSession().selectOne("selectBoard", bo_num);
		return command;
	}

	@Override
	public void updateBo_Count(Integer bo_count) {
		getSqlSession().update("updateBo_count",bo_count);
	}

	@Override
	public void update(BoardCommand boardCommand) {
		System.out.println("boardCommand : " + boardCommand);
		getSqlSession().update("updateBoard",boardCommand);
	}
	@Override
	public void delete(Integer bo_num) {
		getSqlSession().delete("deleteBoard", bo_num);
	}

	@Override
	public List<BoardCommand> getGong() {
		
		List<BoardCommand> list = getSqlSession().selectList("getGong");
		
		return list;
	}

	@Override
	public List<BoardCommand> getJung() {
		
		List<BoardCommand> list = getSqlSession().selectList("getJung");
		
		return list;
	}

	@Override
	public List<BoardCommand> getGallery() {
		
		List<BoardCommand> list = getSqlSession().selectList("getGallery");
		
		return list;
	}
}
